﻿
Partial Class Login
    Inherits System.Web.UI.Page

    Dim controles As New Clases.controles
    Dim db As New Clases.DataBase


    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click

        Dim user As String
        user = db.getSimpleData("select usr_usuarios from tusuarios where usr_usuarios = '" & txtUserName.Text & "'", "usr_usuarios")


        'lbl_usuario.Text = Session("ActiveUserDisplayName")


        If Not user Is Nothing Then
            Dim pass As String
            pass = db.getSimpleData("select usr_contrasena from tusuarios where usr_usuarios = '" & txtUserName.Text & "'", "usr_contrasena")

            If pass.Equals(txtPassword.Text) Then
                Session("ActiveUserlogin") = user

                Session("ActiveUserDisplayName") = db.getSimpleData("select usr_nombre from vwUsuarios where usr_usuarios='" & user & "'", "usr_nombre")
                Session("ActiveUserRol") = db.getSimpleData("select rol_nombre from vwUsuarios where usr_usuarios='" & user & "'", "rol_nombre")

                FormsAuthentication.RedirectFromLoginPage(Session("ActiveUserDisplayName"), False)
            Else
                lblError.Text = "Usuario/Contraseña incorrectos <br /> Intenta de nuevo"
                olvide.Attributes("class") = "forgot2"
            End If
        Else
            lblError.Text = "Usuario/Contraseña incorrectos <br /> Intenta de nuevo"
        End If
    End Sub
End Class
